
import os
"""
os.path:
    abspath(path)        用于获取文件或目录的绝对路径
    exists(path)         用于判断文件或目录是否存在，如果存在返回True，否则返回False
    join(path,name)      将目录与目录或文件名拼接起来
    splitext()           分离文件名和扩展名
    basename(path)       从一个目录中提取文件名
    dirname(path)        从一个路径中提取文件路径，不包括文件名
    isdir(path)          用于判断是否为路径
"""

print(os.path.abspath('12_with.py'))
print(os.path.exists('03_文件读取_打开模式.py'), os.path.exists('07_文件对象_常用方法.py'))
print(os.path.join('../..', '..'))  # ../../..

print(os.path.split('/Users/cdhuangchao3/project/code/python/vippython/chap15/12_with.py'))
print(os.path.splitext('12_with.py'),  # ('12_with', '.py')
      os.path.splitext('/Users/cdhuangchao3/project/code/python/vippython/chap15/12_with.py'))  # ('/Users/cdhuangchao3/project/code/python/vippython/chap15/12_with', '.py')

print(os.path.basename('/Users/cdhuangchao3/project/code/python/vippython/chap15/12_with.py'))  # 12_with.py
print(os.path.dirname('/Users/cdhuangchao3/project/code/python/vippython/chap15/12_with.py'))  # /Users/cdhuangchao3/project/code/python/vippython/chap15
print(os.path.isdir('.'))  # True
